#pragma once
#include "types.h"
#include <vector>

void find_blobs(const uint8_t* binary_img, std::vector<Blob>& blobs) {
    blobs.clear();
    for (int y = 0; y < IMG_H; y += 8) {
        for (int x = 0; x < IMG_W; x += 8) {
            int sum = 0;
            for (int dy = 0; dy < 8; ++dy)
                for (int dx = 0; dx < 8; ++dx)
                    sum += binary_img[(y + dy) * IMG_W + (x + dx)] > 0;

            if (sum > 10) {
                Blob b;
                b.center = {x + 4, y + 4};
                b.width = b.height = 8;
                b.frames_static = 0;
                b.active = true;
                blobs.push_back(b);
                if (blobs.size() >= MAX_OBJECTS) return;
            }
        }
    }
}